package thefirst.support.model;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class NoticeDaoImpl implements NoticeDao {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	@Override
	public void writeNotice(NoticeVO nvo) throws SQLException {
		sqlSessionTemplate.insert("notice.writeNotice",nvo);
	}
	@Override
	public NoticeVO showNoticeInfoNoHits(int no) throws SQLException {
		NoticeVO nvo=sqlSessionTemplate.selectOne("notice.showNoticeInfoNoHits",no);
		System.out.println("Notice dao:"+nvo);
		return nvo;
	}
	@Override
	public void deleteNotice(int no) throws SQLException {
		sqlSessionTemplate.delete("notice.deleteNotice",no);
	}
	@Override
	public int updateNotice(NoticeVO nvo) throws SQLException {
		return sqlSessionTemplate.update("notice.updateNotice",nvo);
	}
	@Override
	public List<NoticeVO> getNoticeList(String pageNo) throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectList("notice.getNoticeList", pageNo);
	}
	@Override
	public int totalNoticeContent() throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectOne("notice.totalNoticeContent");
	}
	@Override
	public int updateHits(int no) throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.update("notice.updateHits",no);
	}
	@Override
	public int updateNoticeNoFile(int no) throws SQLException {
		return sqlSessionTemplate.update("notice.updateNoticeNoFile",no);
	}

}
